package com.be.beadmin.generator.utils;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;


public class ColUtil {
    private static final Logger log = LoggerFactory.getLogger(ColUtil.class);

    public static final Map<String, String> colType = new HashMap<String, String>();

    static  {
        colType.put("tinyint", "Integer");
        colType.put("smallint", "Integer");
        colType.put("mediumint", "Integer");
        colType.put("int", "Integer");
        colType.put("integer", "Integer");
        colType.put("bigint", "Long");
        colType.put("float", "Float");
        colType.put("double", "Double");
        colType.put("decimal", "BigDecimal");
        colType.put("bit", "Boolean");
        colType.put("char", "String");
        colType.put("varchar", "String");

        colType.put("tinytext", "String");

        colType.put("text", "String");
        colType.put("mediumtext", "String");
        colType.put("longtext", "String");
        colType.put("date", "Date");
        colType.put("datetime", "Date");

        colType.put("timestamp", "Timestamp");
        colType.put("tinyblob", "byte[]");
        colType.put("mediumblob", "byte[]");

    }

    /**
     * 转换mysql数据类型为java数据类型
     *
     * @param type 数据库字段类型
     * @return String
     */
    static String cloToJava(String type) {
        return  colType.get(type);
    }
//
//    /**
//     * 获取配置信息
//     */

}
